-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r/aws_launch_template: Fix various bugs #4321
r/aws_launch_template: Fix various bugs #4321
Conversation
…ume, so include it in the example.
I updated the docs to provide some help on the things I had trouble with.. there's an unconventional comment in there that I am not sure how to write in the best way. Please let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @stefansundin -- I would like to get this in before we release v1.16.0 tomorrow so I'll address the feedback in a commit after yours.
Running the acceptance testing is documented at the bottom of the repository README: https://github.com/terraform-providers/terraform-provider-aws/#developing-the-provider
To run the acceptance tests for just this resource, its:
make testacc TEST=./aws TESTARGS='-run=TestAccAWSLaunchTemplate'
@@ -1751,8 +1751,8 @@ func validateLaunchTemplateName(v interface{}, k string) (ws []string, errors [] | |||
errors = append(errors, fmt.Errorf("%q cannot be longer than 99 characters, name is limited to 125", k)) | |||
} else if !strings.HasSuffix(k, "prefix") && len(value) > 125 { | |||
errors = append(errors, fmt.Errorf("%q cannot be longer than 125 characters", k)) | |||
} else if !regexp.MustCompile(`^[0-9a-zA-Z()./_]+$`).MatchString(value) { | |||
errors = append(errors, fmt.Errorf("%q can only alphanumeric characters and ()./_ symbols", k)) | |||
} else if !regexp.MustCompile(`^[0-9a-zA-Z()./_\-]+$`).MatchString(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a dash here looks good according to the EC2 API documentation: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html
LaunchTemplateName
A name for the launch template.
Type: String
Length Constraints: Minimum length of 3. Maximum length of 128.
Pattern: [a-zA-Z0-9\(\)\.-/_]+
Required: Yes
## Example Usage | ||
|
||
```hcl | ||
resource "aws_launch_template" "foo" { | ||
name = "foo" | ||
|
||
block_device_mappings { | ||
device_name = "test" | ||
# to change the type or size of the root volume, override the ami's root device name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add this helper information to the block_device_mappings
documentation below. I'll adjust on merge 👍 More importantly its better to get the updated device_name
information in the example.
@@ -10,16 +10,24 @@ description: |- | |||
|
|||
Provides an EC2 launch template resource. Can be used to create instances or auto scaling groups. | |||
|
|||
-> **Note:** All arguments are optional except for either `name`, or `name_prefix`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this was removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in the commit message, terraform will generate a name if the name is missing. This is also noted in the description of the attribute:
The name of the launch template. If you leave this blank, Terraform will auto-generate a unique name.
@@ -597,7 +597,7 @@ func getBlockDeviceMappings(m []*ec2.LaunchTemplateBlockDeviceMapping) []interfa | |||
ebs["snapshot_id"] = aws.StringValue(v.Ebs.SnapshotId) | |||
} | |||
|
|||
mapping["ebs"] = ebs | |||
mapping["ebs"] = []interface{}{ebs} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An acceptance test implementing this part of the resource would've caught this. I'll add one.
This has been released in version 1.16.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
These three commits fixes the following errors:
I am not sure if there are more things to fix for the middle one.. The problem is that empty strings were used when the properties were not defined (such as
snapshot_id
). I tried to find other places in the code that had similar conventions, and I just used the first one that worked for me.I still haven't learned how to run the tests, so if anyone thinks there needs to be tests added, then please feel free to add them to this PR (edits from maintainers are allowed).